package com.ppc.ugo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ppc.ugo.dao.mapper.GoodPicsMapper;
import com.ppc.ugo.dao.pojo.GoodPics;
import com.ppc.ugo.service.GoodPicsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
@Slf4j
public class GoodPicsServiceImpl implements GoodPicsService {
    @Resource
    private GoodPicsMapper goodPicsMapper;

    @Override
    public void addGoodPics(GoodPics goodPics) {
        goodPicsMapper.insert(goodPics);

        log.info("商品图片添加成功，商品id:{}", goodPics.getGoods_id());
    }

    @Override
    public List<GoodPics> selectByGid(Integer gid) {
        LambdaQueryWrapper<GoodPics> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(GoodPics::getGoods_id, gid);
        List<GoodPics> goodPics = goodPicsMapper.selectList(queryWrapper);
        return goodPics;

    }
}
